<template>
	<view class="wrapper">
		<head-title showLeftButton="true" titleText="TA的动态"></head-title>
		<scroll-view @scrolltolower="comTolower" scroll-y :style="{height:windowH+'px'}" class="wrapper">
			<view class="listCont">
				<view @click="bindCommunity(item.content.id)" class="list" v-for="(item,index) in comList" :key="index">
					<view class="box">
						<view class="user flex_row">
							<image class="headPic" :src="item.user.head_img" mode="aspectFill"></image>
							<view class="text flex_col">
								<view class="name flex_row">
									<text>{{item.user.nickname}}</text>
									<image v-if="item.user.sex==1" src="../../static/image/man.png" mode="aspectFill"></image>
									<image v-else src="../../static/image/woman.png" mode="aspectFill"></image>
								</view>
								<view class="time">{{item.user.send_time}}</view>
							</view>
						</view>
						<view class="words">{{item.content.c_content}}</view>
						<view class="flex_row img" :class="{one:item.img_arr.c_img.length==1,'two':item.img_arr.c_img.length==2}">
							<block v-for="(img,imgs) in item.img_arr.c_img" :key="imgs">
								<image :src="img.c_img" mode="aspectFill"></image>
							</block>
						</view>
					</view>
					<view class="icon flex_row">
						<view class="flex_row">
							<image src="../../static/image/kan.png" mode="aspectFill"></image>
							<text>{{item.last_ceng.see_num}}</text>
						</view>
						<view class="flex_row">
							<image src="../../static/image/pl.png" mode="aspectFill"></image>
							<text>{{item.last_ceng.ping_num}}</text>
						</view>
						<view hover-class="iconHover" class="flex_row">
							<image v-if="item.last_ceng.flower_num==0" src="../../static/image/hua.png" mode="aspectFill"></image>
							<image v-else src="../../static/image/huaon.png" mode="aspectFill"></image>
							<text>{{item.last_ceng.flower_num}}</text>
						</view>
					</view>
				</view>
				<load :loading="loading" :loadTxt="loadTxt"></load>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import common from "../../common/network.js";
	import headTitle from "../../components/headTitle.vue";
	import load from "../../components/load.vue";
	var session = '',userid='',com_page=1,com_fullpage=1;
	export default {
		components:{headTitle,load},
		data(){
			return{
				windowH:0,imgnum:2,
				comList:[],loading:false,loadTxt:'正在加载...',
			}
		},
		onLoad:function(options){
			var that = this;
			if(options.session!=undefined){
				session = options.session;
				com_page = 1;
				userid = options.userid;
				this.com_data();
			}
			common.network.getHeight(function(h,w){
				that.windowH = h-w/750*142;
			})
		},
		methods:{
			com_data:function(shows){
				var that = this;
				var $data = {
					'type':'zcommunity_com_list',
					'session':session,
					'page':com_page,
					'other_uid':userid
				};
				common.network.request($data,function(res){
					com_fullpage = res.pageData.pagecount;
					if(shows){
						that.comList = res.list;
					}else{
						that.comList = (that.comList).concat(res.list);
					}
					that.loading = false;
				})
			},
			bindCommunity:function(id){
				uni.navigateTo({
					url:'/pagesA/trendsDetail/trendsDetail?communityId='+id+'&session='+session
				})
			},
			comTolower:function(){
				console.log('到底了');
				this.loading = true;
				if(com_page>=com_fullpage){
					this.loadTxt = "我是有底线的";
					return false;
				}else{
					this.loadTxt = "正在加载...";
					com_page ++;
					this.com_data();
				}
			},
		}
	}
</script>

<style scoped>
	.list{
		padding-top: 25px;
		border-bottom: 1px solid #f1f1f1;
	}
	.list .box{
		padding: 0 30px;
	}
	.user .text{
		justify-content: space-around;
		align-items: flex-start;
		font-size: 32px;
		font-family: "黑体";
	}
	.headPic{
		width: 90px;
		height: 90px;
		border-radius: 50%;
		margin-right: 20px;
	}
	.name image{
		width: 28px;
		height: 28px;
		margin-left: 14px;
	}
	.time{
		font-size: 26px;
		margin-top: 10px;
		color: #8E8E8E;
	}
	.words{
		max-height: 88px;
		font-size: 30px;
		line-height: 44px;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp:2;
		-webkit-box-orient:vertical;
		color: #3F3F3F;
		margin: 20px 0;
	}
	.img{
		justify-content: space-between;
	}
	.img.one image{
		width: 100%;
		height: 400px;
	}
	.img.two{
		justify-content: flex-start;
	}
	.img.two image{
		margin-right: 20px;
	}
	.img image{
		width: 32%;
		height: 230px;
		border-radius: 6px;
	}
	.icon{
		justify-content: space-between;
	}
	.iconHover{
		background: #f5f5f5;
	}
	.icon view{
		width: 33.33333%;
		font-size: 26px;
		padding: 22px 0;
		justify-content: center;
		color: #8D8D8D;
	}
	.icon image{
		width: 34px;
		height: 34px;
		margin-right: 12px;
	}
</style>
